<?php
/**
 * @date        <!-- phpDesigner :: Timestamp [08-07-2010 00:59:36] -->
 * @filesource  xfunction.misc.php
 * @package     WebCms
 * @copyright	Copyright (C) 2010
 * @author      Sérgio 'Horizak' Alves
 */

// Sem acesso directo
defined('_WEXEC') or die('Restricted access');

/**
 * Alterar idioma
 */
function xajax_changeLang($objResponse,$args = array()) {
  global $cms;
  cms_cookie('siteLang',$args[1],'next year');

  if ($cms->obj['user']->logged()) {
    $userID = $cms->obj['user']->getData('id');
    $sql = 'UPDATE '.DBUSER;
    $sql .= " SET lang ='$args[1]'";
    $sql .= " WHERE id = {$userID}";
    $cms->obj['mysql']->sql($sql);
  }

  $objResponse->redirect(cms_linkReferer());
  return $objResponse;
}
?>